package com.weishaoying.example.base.schedule;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author WeiShaoying
 * @date 2018/4/4
 */
@Service
public class MailService {
    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");

    @Scheduled(fixedRate = 3000, initialDelay = 1000)
    public void send1() {
        System.out.println("发送普通邮件：" + dateFormat.format(new Date()));
    }

    @Scheduled(cron = "0 7 11 ? * *")
    public void send2() {
        System.out.println("发送图片邮件：" + dateFormat.format(new Date()));
    }

}
